<template>
<div class="user-body">
  <div class="user-info-body">
    <div class="user-info">
      <div class="user-head" :style="head" ></div>
      <span class="user-name">{{user.username}}<br> <span class="user-desc">{{user.userdesc}}</span></span>
    </div>
  </div>
  <div class="user-nav">
    <ul class="header-body-nav">
      <li class="header-item"><router-link style="display:inline-block;width: 100%;height: 100%;color: white;font-size: 24px" to="/user/mygame">我的游戏</router-link></li>
      <li class="header-item"><router-link style="display:inline-block;width: 100%;height: 100%;color: white;font-size: 24px" to="/user/historycomments">历史评论</router-link></li>
      <li class="header-item"><router-link style="display:inline-block;width: 100%;height: 100%;color: white;font-size: 24px" to="/user/personalinfo">个人信息</router-link></li>
    </ul>
  </div>
  <input type="button" value="登出" @click="out" style="cursor:pointer;position:absolute;width: 80px;height: 40px;right: 30px;top: 30px;">
  <router-view></router-view>
</div>
</template>

<script>
import {mainStore} from "../../../store";
import {storeToRefs} from 'pinia'
export default {
  name: "index",
  data(){
    const { islogin,user,token } = storeToRefs(mainStore())
    return {
      user,
      islogin,
      token,
      head: ''
    }
  },
  created() {
    this.head = 'background-image: url('+ this.user.userheader +')'
  },
  methods:{
    out(){
      const mainstore = mainStore()
      const { loginout } = mainstore
      loginout()
      this.$router.push({name:'index'}).then(()=>{
        location.reload()
      })
    }
  }
}
</script>

<style scoped>
.user-nav{
  height: 80px;
  background-color: #648ca1;;
}
.header-body-nav{
  display: flex;
  width: 1500px;
  min-height: 100%;
  margin: 0 auto;
}
.header-item{
  height: 100%;
  width: 140px;
  line-height: 80px;
  font-size: 20px;
  text-align: center;
  color: #c5cbd8;
}
.header-item:hover{
  color: blue;
  cursor: pointer;
}

.user-info-body{
  width: 1500px;
  height: 200px;
  background-color: #000000;
  position: relative;
}
.user-info{
  padding: 20px;
  position: absolute;
  bottom: 0;
}
.user-name{
  color: white;
  font-size: 24px;
  margin-left: 17px;
}
.user-desc{

}
.user-head{
  width: 80px;
  height: 80px;
  background-size: 80px;
  display: inline-block;
  vertical-align: top;
}
.user-body{
  width: 1500px;
  height: 1500px;
  margin: 0 auto;
  position: relative;
}
</style>
